#pragma once

#include <event2/event.h>
#include <vector>
#include <memory>
#include <mutex>
#include <thread>
#include <atomic>
#include <assert.h>
#include <iostream>
#include <cstring>

class EventbasePool
{
public:
    EventbasePool();
    ~EventbasePool();

    void start(int size);

    void stop();

    std::shared_ptr<event_base> getNextBase();

private:
    std::atomic<bool> started_;
    int nextPool_;
    std::mutex mutex_;
    std::vector<std::unique_ptr<std::thread>> workThreads_;
    std::vector<std::shared_ptr<event_base>> eventbasePool_;
};